package org.streamerstudio.ui.properties;

import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import org.streamerstudio.model.gstreamer.registry.GstElement;

public class ElementPropertySection extends AbstractPropertySection {

	private ElementPropertyComposite elementComposite;
	
	public ElementPropertySection() {
	}

	@Override
	public void createControls(Composite parent,
			TabbedPropertySheetPage aTabbedPropertySheetPage) {
		super.createControls(parent, aTabbedPropertySheetPage);
		elementComposite = new ElementPropertyComposite(parent, SWT.NONE);
	}

	@Override
	public void refresh() {
		if (elementComposite != null){
			elementComposite.update();
		}
	}

	@Override
	public void setInput(IWorkbenchPart part, ISelection selection) {
		super.setInput(part, selection);
        if (selection instanceof IStructuredSelection){
	        Object input = ((IStructuredSelection) selection).getFirstElement();
	        if (GstElement.class.isAssignableFrom(input.getClass())){
	        	elementComposite.setInput((GstElement)input);
	        }
        }
	}

	
}
